package com.niji.littly_donkey_android.activity;

import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.niji.littly_donkey_android.R;
import com.niji.littly_donkey_android.http.ConnectViaSession;
import com.niji.littly_donkey_android.util.StatusBarUtil;

public class SettingActivity extends BaseActivity {

    private Button setting_return;
    
    private RelativeLayout black_list;
    
    private RelativeLayout message_setting;

    private RelativeLayout version;

    private RelativeLayout feed_back;

    @Override
    public void onCreate(final Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.setting_activity);
        settingReturn();
        blackList();
        messageSetting();
        versionInfo();
        feedBack();
        exitBtn();
    }

    /**
     * 退出登录
     */
    private void exitBtn() {
        Button exit_btn = findViewById(R.id.exit_btn);
        exit_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new ConnectViaSession(SettingActivity.this).SaveSession(null);
                Intent intent = new Intent(SettingActivity.this, IndexActivity.class);
                intent.putExtra("loginCode","-1");
                Toast.makeText(SettingActivity.this,"退出登录成功",Toast.LENGTH_SHORT).show();
                startActivity(intent);
                overridePendingTransition(R.anim.xpage_slide_in_left,R.anim.xpage_slide_out_right);
                finish();
            }
        });
    }

    @Override
    protected int getLayoutId() {
        return R.layout.setting_activity;

    }
    @Override
    protected int getStatusBarColor() {
        return R.color.white_easy_photos;
    }

    /**
     * 意见反馈
     */
    private void feedBack() {
        feed_back = findViewById(R.id.feed_back);
        feed_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(SettingActivity.this, FeedBackActivity.class));
            }
        });
    }

    /**
     * 版本信息
     */
    private void versionInfo() {
        version = findViewById(R.id.version);
        version.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(SettingActivity.this, VersionActivity.class));
            }
        });
    }

    /**
     * 消息设置
     */
    private void messageSetting() {
        message_setting = findViewById(R.id.message_setting);
        message_setting.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(SettingActivity.this, MessageSettingActivity.class));
            }
        });
    }

    /***
     * 黑名单
     */
    private void blackList() {
        black_list = findViewById(R.id.black_list);
        black_list.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(SettingActivity.this, BlackListActivity.class));
            }
        });
    }

    /**
     * 返回
     */

    private void settingReturn() {
        setting_return = findViewById(R.id.setting_return);
        setting_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                overridePendingTransition(R.anim.xpage_slide_in_left,R.anim.xpage_slide_out_right);
                finish();
            }
        });

    }
}
